<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>员工信息管理</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            background: url('/images/2.jpg') no-repeat center center fixed;
            background-size: cover;
            font-family: "微软雅黑", sans-serif;
        }
        .main-content {
            margin-left: 200px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.5);
            min-height: calc(100vh - 50px);
        }
        .breadcrumb { margin-bottom: 20px; color: #0e0e0e; }
        .breadcrumb a { color: #0e0e0e; text-decoration: none; }
        .search-bar {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        .search-bar input {
            padding: 5px 8px;
            border: 1px solid #ccc;
            border-radius: 3px;
            margin-right: 10px;
        }
        .search-bar button {
            padding: 5px 15px;
            background-color: #1773d0;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        .btn-group { margin-bottom: 15px; }
        .btn-group a {
            padding: 6px 12px;
            margin-right: 10px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            color: #fff;
            text-decoration: none;
            display: inline-block;
        }
        .btn-add { background-color: #5cb85c; }
        .table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }
        .table thead { background-color: #902d2d; color: #fff; }
        .table th, .table td {
            border: 1px solid #ddd;
            padding: 8px 10px;
            text-align: center;
        }
        .table tbody tr:nth-child(even) { background-color: #f9f9f9; }
        .operate-btn {
            padding: 4px 8px;
            margin: 0 2px;
            border: none;
            border-radius: 2px;
            color: #fff;
            text-decoration: none;
            font-size: 12px;
        }
        .btn-edit { background-color: #337ab7; }
        .btn-remove { background-color: #d9534f; }
    </style>
</head>
<body>
<div th:replace="~{common/common::topbar}"></div>
<div th:replace="~{common/common::sidebar}"></div>

<div class="main-content">
    <div class="breadcrumb">
        <a href="/login.html">系统首页</a> > 员工信息管理
    </div>

    <form action="/employee_info/list" method="get" class="search-bar">
        <label for="searchInput">搜索：</label>
        <input type="text" id="searchInput" name="name" placeholder="请输入员工姓名">
        <button type="submit">查询</button>
    </form>

    <div class="btn-group">
        <a th:href="@{/employee_info/add}" class="btn-add">新增</a>
    </div>

    <table class="table">
        <thead>
        <tr>
            <th><input type="checkbox"></th>
            <th>ID</th>
            <th>员工姓名</th>
            <th>职位</th>
            <th>入职日期</th>
            <th>工作状态</th>
            <th>权限</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="employee : ${employeeLists}">
            <td><input type="checkbox"></td>
            <td th:text="${employee.id}"></td>
            <td th:text="${employee.employeeName}"></td>
            <td th:text="${employee.position}"></td>
            <td th:text="${#dates.format(employee.hireDate, 'yyyy-MM-dd')}"></td>
            <td th:text="${employee.workStatus == 1 ? '在职' : '离职'}"></td>
            <td th:text="${employee.permission == 2 ? '管理员' : '普通员工'}"></td>
            <td th:text="${#dates.format(employee.updateTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
            <td>
                <a th:href="@{/employee_info/edit/{id}(id=${employee.id})}" class="operate-btn btn-edit">修改</a>
                <a th:href="@{/employee_info/delete(id=${employee.id})}" class="operate-btn btn-remove"
                   onclick="return confirm('确定删除吗？')">删除</a>
            </td>
        </tr>
        <tr th:if="${employeeLists == null or employeeLists.isEmpty()}">
            <td colspan="9" class="text-center">暂无数据</td>
        </tr>
        </tbody>
    </table>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        const sidebarItems = document.querySelectorAll('.sidebar li a');
        sidebarItems.forEach(item => {
            if (item.getAttribute('href') === '/employee_info/list') {
                item.parentElement.classList.add('active');
            }
        });
    });
</script>
</body>
</html>